package com.gxa.service.impl;

import com.gxa.mapper.UserMapper;
import com.gxa.pojo.User;
import com.gxa.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("loginByNameService")
public class LoginByNameService implements LoginService {

    @Autowired
    private UserMapper userMapper;

    /**
     * 更新用户登录时间
     * @param user
     * @return
     */
    @Override
    public Integer updateLoginTime(User user) {
        return userMapper.updateByPrimaryKeySelective(user);
    }

    /**
     * 登录
     * @param user
     * @return
     */
    @Override
    public User login(User user) {
        return userMapper.findUserByName(user.getUserName());
    }

    /**
     * 根据Id查询User的详细信息
     * @param userId
     * @return
     */
    @Override
    public User findUserDetail(Integer userId) {
        return userMapper.findById(userId);
    }
}
